import time,pytest
from playwright.sync_api import Playwright,sync_playwright

@pytest.fixture
def page():
    with sync_playwright() as e:
        browser = e.chromium.launch(headless=False)
        page = browser.new_page()
        yield page
        page.close()

def test_01(page):
    page.goto('https://www.jiuxian.com/')
    page.click('xpath=/html/body/div[2]/div/div[1]/div/a[1]')
    dy1 = page.locator('a[class="userLogin on"]').text_content()
    print(dy1)
    page.fill('input[id="userName"]','15235688537')
    page.fill('input[id="password"]','Aa123123')
    time.sleep(15)
    page.click('input[id="save"]')
    page.click('a[id="bindSub"]')
    time.sleep(5)

def test_02(page):
    test_01(page)
    page.click('xpath=/html/body/div[3]/div/div[2]/div[2]/p/a[3]')
    page.go_forward()
    page.goto('https://list.jiuxian.com/1-3-0-0-0-0-0-0-0-0-0-0.htm?area=2#v2')
    time.sleep(3)
    page.click('xpath=/html/body/div[6]/div/div[2]/div[6]/ul/li[1]/div[2]/div[1]/a/img')
    time.sleep(5)
